Completed
Pull Request — master (#120)
by Maxence
03:22
created

members.searchUsers   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
/*
2
 * Circles - Bring cloud-users closer together.
3
 *
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later. See the COPYING file.
6
 *
7
 * @author Maxence Lange <[email protected]>
8
 * @copyright 2017
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
/** global: OC */
27
/** global: OCA */
28
29
var members = {
30
31
32
	searchUsers: function (search, callback) {
33
34
		var result = {status: -1};
35
		$.ajax({
36
			method: 'GET',
37
			url: OC.generateUrl('/apps/circles/v1/globalsearch'),
38
			data: {
39
				search: search
40
			}
41
		}).done(function (res) {
42
			api.onCallback(callback, res);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
43
		}).fail(function () {
44
			api.onCallback(callback, result);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
45
		});
46
	},
47
48
49
	addMember: function (circleId, ident, type, callback) {
50
		var result = {status: -1};
51
		$.ajax({
52
			method: 'PUT',
53
			url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/member'),
54
			data: {
55
				ident: ident,
56
				type: type
57
			}
58
		}).done(function (res) {
59
			api.onCallback(callback, res);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
60
		}).fail(function () {
61
			api.onCallback(callback, result);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
62
		});
63
	},
64
65
66
	removeMember: function (circleId, userId, userType, callback) {
67
		var result = {status: -1};
68
		$.ajax({
69
			method: 'DELETE',
70
			url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/member'),
71
			data: {
72
				member: userId,
73
				type: Number(userType)
74
			}
75
		}).done(function (res) {
76
			api.onCallback(callback, res);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
77
		}).fail(function () {
78
			api.onCallback(callback, result);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
79
		});
80
	},
81
82
83
	levelMember: function (circleId, userId, userType, level, callback) {
84
		var result = {status: -1};
85
		$.ajax({
86
			method: 'POST',
87
			url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/level'),
88
			data: {
89
				member: userId,
90
				type: userType,
91
				level: level
92
			}
93
		}).done(function (res) {
94
			api.onCallback(callback, res);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
95
		}).fail(function () {
96
			api.onCallback(callback, result);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
97
		});
98
	}
99
100
101
};
102
103